package com.soft.zosagent.zoscls;

import com.ibm.jzos.MvsCommandCallback;
import com.ibm.jzos.MvsConsole;
import com.ibm.jzos.WtoConstants;

/**
 * @description: mainframe 命令行接受类
 * @author: cinbo，chenyinbo
 * @create: 2020-12-03 14:39
 */
public class MyMvsCommandCallback implements MvsCommandCallback {
    public String modifyCommand = null;
    public String startParameters = null;

    @Override
    synchronized public void handleModify(String modifyCommand) {
        this.modifyCommand = modifyCommand;
        //Notify the waiting caller that a command has been received.
        notify();
    }

    @Override
    public void handleStart(String startParameters) {
        this.startParameters = startParameters;
        MvsConsole.wto("START command received.  Parameters=" +
                        startParameters != null ? startParameters : "<NONE>",
                WtoConstants.ROUTCDE_PROGRAMMER_INFORMATION,
                WtoConstants.DESC_IMPORTANT_INFORMATION_MESSAGES);
    }

    @Override
    public boolean handleStop() {
        MvsConsole.wto("STOP command received. Please use modify command to exit.",
                WtoConstants.ROUTCDE_PROGRAMMER_INFORMATION,
                WtoConstants.DESC_IMPORTANT_INFORMATION_MESSAGES);
        //System.out.println("Finished processing.");
        return false; // Allow System.exit() to be performed.
    }
};
